home *** CD-ROM | disk | FTP | other *** search
Visual Basic class definition | 1998-12-19 | 2.7 KB | 81 lines |
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- END
- Attribute VB_Name = "clsBorder"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Dim initBoxStyle As Long
- Dim initLeft As Integer
- Dim initTop As Integer
- Dim initWidth As Integer
- Dim initHeight As Integer
- ' 'windows constants
- Const SWP_DRAWFRAME = &H20
- Const SWP_NOMOVE = &H2
- Const SWP_NOSIZE = &H1
- Const SWP_NOZORDER = &H4
- Const SWP_FLAGS = SWP_NOZORDER Or SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME
- Const GWL_STYLE = (-16)
- Const WS_THICKFRAME = &H40000
-
- Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
- (ByVal hwnd As Long, ByVal nIndex As Long) As Long
-
- Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
- (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
-
- Private Declare Function SetWindowPos Lib "user32" _
- (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
- ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
- ByVal cy As Long, ByVal wFlags As Long) As Long
- Private Properties As New clsProperties
- Public Sub AddResizerToObject(Object As Object)
- Dim style As Long
- Dim SysMenuKillFlag As Integer
- style& = GetWindowLong(Object.hwnd, GWL_STYLE)
- Properties.AddProperty "Style", CStr(Object.Name), style&, Object
- Properties.AddProperty "HasBorder", CStr(Object.Name), "Yes", Object
- style& = style& Or WS_THICKFRAME
- SetControlStyle style&, Object.hwnd, Object.Container.hwnd
- End Sub
-
- Public Sub RemoveResize(Object As Object)
- If Properties.ReturnProperty(Object.Name, "Style") Is Nothing Then
- Exit Sub
- End If
- SetControlStyle Properties.ReturnProperty(Object.Name, "Style").PValue, Object.hwnd, Object.Parent.hwnd
- Properties.DeleteProperty Object.Name, "Style"
- Properties.DeleteProperty Object.Name, "HasBorder"
- End Sub
-
- Private Sub SetControlStyle(style&, ObjecthWnd As Long, ParentHwnd As Long)
- Dim r&
- If style& Then
- r& = SetWindowLong(ObjecthWnd, GWL_STYLE, style&)
- r& = SetWindowPos(ObjecthWnd, ParentHwnd, 0, 0, 0, 0, SWP_FLAGS)
- End If
- End Sub
-
- Public Sub ToggleBorder(Object As Object)
- If Properties.ReturnProperty(Object.Name, "HasBorder") Is Nothing Then
- AddResizerToObject Object
- Else
- RemoveResize Object
- End If
- End Sub
-
-
- Public Sub KillAllBorders()
- Dim I As Long
- For I = 1 To Properties.Count
- If Properties.ReturnPByIdx(I) Is Nothing Then Exit For
- If Properties.ReturnPByIdx(I).PName = "Style" Then
- RemoveResize Properties.ReturnPByIdx(I).ObjectReferense
- I = I - 1
- End If
- Next
- End Sub
-